import React, {useRef, useState} from 'react';

function App(props) {
    /**
     * 函数是没有ref的，可以借助useRef让函数组件可以方便获取真实DOM
     */
    let [num, setNum] = useState(0);
    const h3Ref = useRef()
    return (
        <div>
            <h3 ref={h3Ref}>App</h3>
            <button onClick={() => {
                console.log("ref", h3Ref.current.innerText); // 获取真实DOM
                setNum(h3Ref.current.innerText)
            }}>{num}</button>
        </div>
    );
}

export default App;